<template>
	<view>
		<view class="container" v-if=" userInfo.user_id > 0 ">

			<view class="space-upper">
				<view class="wallet-image">
					<image src="/static/img/wallet.png" mode="widthFix"></image>
				</view>
				<view class="wallet-account">
					<view class="wallet-account_balance">
						<text>{{ userInfo.balance }}</text>
					</view>
					<view class="wallet-account_lable">
						<text>账户余额(元)</text>
					</view>
				</view>
			</view>

			<view class="space-lower">
				<view v-if="setting.is_entrance" class="space-lower_item btn-recharge">
					<form @submit="onTargetRecharge" report-submit="true">
						<button form-type="submit" class="btn-submit">充 值</button>
					</form>
				</view>
				<view class="space-lower_item item-lable dis-flex flex-x-around">
					<form @submit="onTargetRechargeOrder" report-submit="true">
						<button form-type="submit" class="btn-normal">
							<view class="lable-text">
								<text>充值记录</text>
							</view>
						</button>
					</form>
					<form @submit="onTargetBalanceLog" report-submit="true">
						<button form-type="submit" class="btn-normal">
							<view class="lable-text">
								<text>账单详情</text>
							</view>
						</button>
					</form>
				</view>
			</view>

		</view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				userInfo: {},
				setting:{is_entrance: false}
			}
		},

		/**
		 * 生命周期函数--监听页面显示
		 */
		onShow() {
			let _this = this;
			// 获取我的钱包
			_this.getUserDetail();
		},

		methods: {

			/**
			 * 获取我的钱包
			 */
			getUserDetail: function() {
				let _this = this;
				_this._get('user.wallet/index', {}, function(result) {
					_this.setData(result.data);
				});
			},


			/**
			 * 跳转充值页面
			 */
			onTargetRecharge(e) {
				let _this = this;
				// 记录formId
				_this.saveFormId(e.detail.formId);
				uni.navigateTo({
					url: '../recharge/recharge'
				})
			},

			/**
			 * 跳转充值记录页面
			 */
			onTargetRechargeOrder(e) {
				let _this = this;
				// 记录formId
				_this.saveFormId(e.detail.formId);
				uni.navigateTo({
					url: '../recharge/order/order'
				})
			},

			/**
			 * 跳转账单详情页面
			 */
			onTargetBalanceLog(e) {
				let _this = this;
				// 记录formId
				_this.saveFormId(e.detail.formId);
				uni.navigateTo({
					url: '../wallet/balance/balance'
				})
			},
		}
	}
</script>

<style>
	page,
	.container {
		background: #fff;
	}

	.space-upper {
		padding: 150upx 0;
		text-align: center;
	}

	.wallet-image image {
		width: 360upx;
		height: 261.72upx;
	}

	.wallet-account {
		margin-top: 20upx;
	}

	.wallet-account_balance {
		font-size: 52upx;
	}

	.wallet-account_lable {
		margin-top: 10upx;
		color: #cec1c1;
		font-size: 24upx;
	}

	.space-lower {
		margin-top: 30upx;
		padding: 0 110upx;
	}

	.btn-recharge button.btn-submit {
		font-size: 30upx;
		background: #786cff;
		border: none;
		color: white;
		border-radius: 50upx;
		padding: 0 120upx;
		line-height: 2.8;
	}

	.item-lable {
		margin-top: 80upx;
		font-size: 26upx;
		color: rgb(94, 94, 94);
		padding: 0 100upx;
	}
</style>
